package com.springsummer.information.green.beans;

public class ClassPathXmlApplicationContext extends GenericApplicationContext {

    protected XmlBeanDefinitionReader xmlBeanDefinitionReader;

    public ClassPathXmlApplicationContext() {
        super();
    }

    public ClassPathXmlApplicationContext(String configLocation) {
        super(configLocation,new DefaultListableBeanFactory());

        try {

            //load(resources);
            //refresh();
            createReader();

            load();
            refresh();

        } catch (Exception e) {
            throw new RuntimeException(e);
        }
    }

    private void load() throws Exception {
        xmlBeanDefinitionReader.loadBeanDefinitions(getConfigLocation());
    }

    protected void createReader() throws Exception {
        BeanDefinitionRegistry beanDefinitionRegistry = (BeanDefinitionRegistry) getBeanFactory();
        this.xmlBeanDefinitionReader = new XmlBeanDefinitionReader(beanDefinitionRegistry);
    }

    @Override
    protected void onRefresh(ConfigurableListableBeanFactory beanFactory) {
        super.onRefresh(beanFactory);
    }

}









